package com.unicom.priceboard.data.vo;

import java.util.HashMap;

import com.unicom.priceboard.util.NumberUtil;

public class HoIndex {
	private String change;
	private String changePer;
	private String changePerFormat;
	private String changePerVNIndex;
	private String session;
	private String totalTrade;//
	private String vnIndex_date;
	private String vnIndex;
	private String totalValueFormat;
	private String totalValue;
	private String totalShares;
	private int idSession;
	private String css = "";
	private String indicator = "";
	private String numberSign = "";
	private String marketState = "";
	private HashMap<String,String> mapCSS = new HashMap<String, String>();
	private HashMap<String,String> mapIndicator = new HashMap<String, String>();

	public HoIndex() {
	  	mapCSS.put("up", "index_up");
	  	mapCSS.put("down", "index_down");
	  	mapCSS.put("unchange", "index_unchange");

	  	mapIndicator.put("up", "images/up.gif");
	  	mapIndicator.put("down", "images/down.gif");
	  	mapIndicator.put("unchange", "");
	  }

	public String getChange() {
		return change;

	}
	public void setChange(String change) {
		this.change = change;
		String key = Double.parseDouble(change)>0?"up":(Double.parseDouble(change)<0?"down":"unchange");
		this.numberSign = key.equals("up")?"+":(key.equals("down")?"-":"");
		this.css = mapCSS.get(key);
		this.indicator = mapIndicator.get(key);
	}


	public String getVnIndex() {
		return vnIndex;
	}

	public void setVnIndex(String vnIndex) {
		this.vnIndex = NumberUtil.index(vnIndex);
	}

	public String getTotalValue() {
		return totalValue;
	}
	public void setTotalValue(String totalvalue) {
		this.totalValue = totalvalue;
		if(totalvalue.equals("0")||totalvalue.equals("0.0")){
			this.totalValueFormat="";
		}else{
			this.totalValueFormat=NumberUtil.formatHose_MarketValue(Double.valueOf(totalvalue.replace(",","")));
		}

	}
	public String getTotalShares() {
		return totalShares;
	}
	public void setTotalShares(String totalShares) {
		this.totalShares = totalShares;
	}
	public String getChangePer() {
		return changePer;
	}
	public void setChangePer(String changePer) {
		this.changePer = changePer;
		if(!changePer.equals("0.0")){
			if(Double.parseDouble(changePer)>0){
				this.changePerFormat="(+"+changePer+"%)";
			}else
				this.changePerFormat="("+changePer+"%)";
		}else{
			this.changePerFormat="";
		}

		if(Double.parseDouble(changePer)>0){
			this.changePerVNIndex="(+"+changePer+"%)";
		}else if(Double.parseDouble(changePer)<0){
			this.changePerVNIndex="("+changePer+"%)";
		}else{
			this.changePerVNIndex="";
		}
	}
	public String getTotalTrade() {
		return totalTrade;
	}
	public void setTotalTrade(String totalTrade) {
		this.totalTrade = totalTrade;
	}
	public String getVnIndex_date() {
		return vnIndex_date;
	}
	public void setVnIndex_date(String vnIndex_date) {
		this.vnIndex_date = vnIndex_date;
	}
	public String getSession() {
		return session;
	}
	public void setSession(String session) {
		this.session = session;
	}

	public String getMarketState() {
		return marketState;
	}

	public void setMarketState(String marketState) {
		this.marketState = marketState;
	}

	public int getIdSession() {
		return idSession;
	}

	public void setIdSession(int idSession) {
		this.idSession = idSession;
	}

	public String getCss() {
		return css;
	}

	public void setCss(String css) {
		this.css = css;
	}

	public String getIndicator() {
		return indicator;
	}

	public void setIndicator(String indicator) {
		this.indicator = indicator;
	}

	public String getNumberSign() {
		return numberSign;
	}

	public void setNumberSign(String numberSign) {
		this.numberSign = numberSign;
	}

	public boolean equals(Object obj) {
		if(!this.getClass().isInstance(obj))
			return false;
		else{
			HoIndex compareObject = (HoIndex)obj;
			totalValueFormat=totalValueFormat.trim();
			vnIndex=vnIndex.trim();
			totalShares=totalShares.trim();
			vnIndex=NumberUtil.index(vnIndex);
			if(!vnIndex.equals(compareObject.getVnIndex())) {
				return false;
			}else if(!totalShares.equals(compareObject.getTotalShares())){
				return false;
			}else if(!totalValueFormat.equals(compareObject.getTotalValueFormat())){
				return false;
			}
			else{
				return true;
			}
		}
	}

	public String getTotalValueFormat() {
		return totalValueFormat;
	}

	public void setTotalValueFormat(String totalvalueFormat) {
		this.totalValueFormat = totalvalueFormat;
	}

	public String getChangePerFormat() {
		return changePerFormat;
	}

	public void setChangePerFormat(String changePerFormat) {
		this.changePerFormat = changePerFormat;
	}

	public String getChangePerVNIndex() {
		return changePerVNIndex;
	}

	public void setChangePerVNIndex(String changePerVNIndex) {
		this.changePerVNIndex = changePerVNIndex;
	}


}
